﻿using clf.dongle;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace weighing
{
    public class ActiveDongleHelper
    {
        #region variables
        //加密内容：
        private static string EncryptContent = "CopyRight-Bnhq";

        //密文 ：        
        private static string DecryptContent = "C43B4CFD511E7855742D426E687100";
        #endregion

        #region instance

        private static IDongle _mDongle;

        public static IDongle Instance
        {
            get
            {
                if (_mDongle == null)
                {
                    _mDongle = new YT88();
                }
                return _mDongle;
            }
        }
        #endregion

        public static bool IsActived() {

            string encStr = Instance.Read(1, 50);
            string a = encStr.Replace("\u001e","").ToString();
            //string decStr = Instance.Decrypt(a);

            if(DecryptContent == a)
            {
                return true;
            }

            return false;   
        }

        public static int WriteKey()
        {
          return Instance.Write(DecryptContent, 1);
        }
    }
}
